package Logic;

import java.util.Random;

import javax.swing.DefaultListModel;

import utils.IniFile;
import utils.Vec;

import irio.gamer.gamer;

public class Renderlist {

	
	public static void createLamer(String filename, String galaxyName, Vec orientation) {
		String s = galaxyName + " 0 0 0 " + orientation.x + " " + orientation.y + " " + orientation.z + " 1 1 ";
		IniFile.SaveTextfile(filename, s);
		
	}
	

	public static void Create(String filename, DefaultListModel list) {
	
		Random rnd = new Random();
		Vec pos = new Vec();
		Vec orientation = new Vec();
		String contents = "";
		for (int i=0;i<gamer.gamerParams.renderlistCount.x;i++) {
			String galaxy = (String)list.get( rnd.nextInt(list.size()));
			orientation.set(5,5,5);
			orientation.randomize(rnd);
			orientation.normDirect();
			
			pos.set(gamer.gamerParams.renderlistSize.x,gamer.gamerParams.renderlistSize.x,gamer.gamerParams.renderlistSize.x);
			pos.randomize(rnd);

			double magnitude = rnd.nextDouble()*1.0 + 0.0;
			double redshift = rnd.nextDouble()*0.4 + 0.8;
			
			contents += galaxy + " " + pos.x + " " + pos.y + " " + pos.z + " ";
			contents += orientation.x + " " + orientation.y + " " + orientation.z + " " + magnitude + "  " + redshift + " \n";
		}
		IniFile.SaveTextfile(filename, contents);
	}
	
	
}
